﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ConfeccionesJR.UI
{
    public partial class frmMENU : Form
    {
        public frmMENU()
        {
            InitializeComponent();
            this.BuildUp();
        }

        float f_HeightRatio = new float();
        float f_WidthRatio = new float();

        public void ResizeForm(Form ObjForm, int DesignerHeight, int DesignerWidth)
        {
            #region Code for Resizing and Font Change According to Resolution

            int i_StandardHeight = DesignerHeight;
            int i_StandardWidth = DesignerWidth;
            int i_PresentHeight = Screen.PrimaryScreen.Bounds.Height;
            int i_PresentWidth = Screen.PrimaryScreen.Bounds.Width;
            f_HeightRatio = (float)((float)i_PresentHeight / (float)i_StandardHeight);
            f_WidthRatio = (float)((float)i_PresentWidth / (float)i_StandardWidth);
            ObjForm.AutoScaleMode = AutoScaleMode.None;
            ObjForm.Scale(new SizeF(f_WidthRatio, f_HeightRatio));
            foreach (Control c in ObjForm.Controls)
            {
                if (c.HasChildren)
                {
                    ResizeControlStore(c);
                }
                else
                {
                    c.Font = new Font(c.Font.FontFamily, c.Font.Size * f_HeightRatio, c.Font.Style, c.Font.Unit, ((byte)(0)));
                }
            }
            ObjForm.Font = new Font(ObjForm.Font.FontFamily, ObjForm.Font.Size * f_HeightRatio, ObjForm.Font.Style, ObjForm.Font.Unit, ((byte)(0)));
            #endregion
        }

        private void ResizeControlStore(Control objCtl)
        {
            #region

            if (objCtl.HasChildren)
            {
                foreach (Control cChildren in objCtl.Controls)
                {
                    if (cChildren.HasChildren)
                    {
                        ResizeControlStore(cChildren);
                    }
                    else
                    {
                        cChildren.Font = new Font(cChildren.Font.FontFamily, cChildren.Font.Size * f_HeightRatio, cChildren.Font.Style, cChildren.Font.Unit, ((byte)(0)));
                    }
                }
                objCtl.Font = new Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, ((byte)(0)));
            }
            else
            {
                objCtl.Font = new Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, ((byte)(0)));
            }
            #endregion
        }

        private void frmMENU_Load(object sender, EventArgs e)
        {
            //this.ResizeForm(this, 768, 1366); 
        }

        private void nuevoProducto_Click(object sender, EventArgs e)
        {
            frmMttoProducto frm = new frmMttoProducto();
            frm.MdiParent = this;
            frm.Nuevo();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void buscarProducto_Click(object sender, EventArgs e)
        {
            frmProducto frm = new frmProducto();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void nuevoMaterial_Click(object sender, EventArgs e)
        {
            frmMttoMaterial frm = new frmMttoMaterial();
            frm.MdiParent = this;
            frm.Nuevo();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void buscarMaterial_Click(object sender, EventArgs e)
        {
            frmMaterial frm = new frmMaterial();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void busVenta_Click(object sender, EventArgs e)
        {
            frmVenta frm = new frmVenta();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void regVenta_Click(object sender, EventArgs e)
        {
            frmMttoVenta frm = new frmMttoVenta();
            frm.MdiParent = this;
            frm.Nuevo();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void busProforma_Click(object sender, EventArgs e)
        {
            FrmProforma frm = new FrmProforma();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void regProforma_Click(object sender, EventArgs e)
        {
            frmMttProforma frm = new frmMttProforma();
            frm.MdiParent = this;
            frm.AddProforma();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void buscarCredito_Click(object sender, EventArgs e)
        {
            frmCredito frm = new frmCredito();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void nuevoCredito_Click(object sender, EventArgs e)
        {
            frmMttoCredito frm = new frmMttoCredito();
            frm.MdiParent = this;
            frm.Nuevo();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void buscarCompra_Click(object sender, EventArgs e)
        {
            FrmCompra frm = new FrmCompra();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void nuevaCompra_Click(object sender, EventArgs e)
        {
            frmMttoCompra frm = new frmMttoCompra();
            frm.MdiParent = this;
            frm.Nuevo();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void busCliente_Click(object sender, EventArgs e)
        {
            frmCliente frm = new frmCliente();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void regCliente_Click(object sender, EventArgs e)
        {
            frmMttoCliente frm = new frmMttoCliente();
            frm.MdiParent = this;
            frm.AddCliente();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void busProveedor_Click(object sender, EventArgs e)
        {
            FrmProveedor frm = new FrmProveedor();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void regProveedor_Click(object sender, EventArgs e)
        {
            FrmMttoProveedor frm = new FrmMttoProveedor();
            frm.MdiParent = this;
            frm.Nuevo();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void buscarUndMedida_Click(object sender, EventArgs e)
        {
            frmUnidadMedida frm = new frmUnidadMedida();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void nuevaUndMedida_Click(object sender, EventArgs e)
        {
            frmMttoUndMedida frm = new frmMttoUndMedida();
            frm.MdiParent = this;
            frm.Nuevo();
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

        private void buscarRegNeg_Click(object sender, EventArgs e)
        {
            frmImpuesto frm = new frmImpuesto();
            frm.MdiParent = this;
            frm.Show();
            radRibbonBar1.Expanded = false;
        }

   

    }
}
